<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="方案id" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fanganId">
              <a-input v-model="model.fanganId" placeholder="请输入方案id"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="降阻剂代号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="djzjdh">
              <a-input v-model="model.djzjdh" placeholder="请输入降阻剂代号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="降阻剂加量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="djzjjl">
              <a-input v-model="model.djzjjl" placeholder="请输入降阻剂加量"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="助排剂代号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dzpjdh">
              <a-input v-model="model.dzpjdh" placeholder="请输入助排剂代号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="助排剂加量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dzpjjl">
              <a-input v-model="model.dzpjjl" placeholder="请输入助排剂加量"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="杀菌剂代号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dsjjdh">
              <a-input v-model="model.dsjjdh" placeholder="请输入杀菌剂代号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="杀菌剂加量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dsjjjl">
              <a-input v-model="model.dsjjjl" placeholder="请输入杀菌剂加量"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="稠化剂代号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zchj">
              <a-input v-model="model.zchj" placeholder="请输入稠化剂代号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="稠化剂加量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zchjjl">
              <a-input v-model="model.zchjjl" placeholder="请输入稠化剂加量"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="流变改进剂代号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zlbgjjdh">
              <a-input v-model="model.zlbgjjdh" placeholder="请输入流变改进剂代号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="流变改进剂加量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zlbgjjjl">
              <a-input v-model="model.zlbgjjjl" placeholder="请输入流变改进剂加量"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="助排剂代号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zzpjdh">
              <a-input v-model="model.zzpjdh" placeholder="请输入助排剂代号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="助排剂加量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zzpjjl">
              <a-input v-model="model.zzpjjl" placeholder="请输入助排剂加量"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="杀菌剂代号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zsjjdh">
              <a-input v-model="model.zsjjdh" placeholder="请输入杀菌剂代号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="杀菌剂加量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zsjjjl">
              <a-input v-model="model.zsjjjl" placeholder="请输入杀菌剂加量"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="破胶剂代号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zpjjdh">
              <a-input v-model="model.zpjjdh" placeholder="请输入破胶剂代号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="破胶剂加量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zpjjjl">
              <a-input v-model="model.zpjjjl" placeholder="请输入破胶剂加量"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="盐酸代号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sysdh">
              <a-input v-model="model.sysdh" placeholder="请输入盐酸代号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="盐酸加量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sysjl">
              <a-input v-model="model.sysjl" placeholder="请输入盐酸加量"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="缓剂蚀代号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shsjdh">
              <a-input v-model="model.shsjdh" placeholder="请输入缓剂蚀代号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="缓蚀剂加量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="shsjl">
              <a-input v-model="model.shsjl" placeholder="请输入缓蚀剂加量"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="助排剂代号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="szpjdh">
              <a-input v-model="model.szpjdh" placeholder="请输入助排剂代号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="助排剂加量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="szpjjl">
              <a-input v-model="model.szpjjl" placeholder="请输入助排剂加量"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="铁离子稳定剂代号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="stlzwdjdh">
              <a-input v-model="model.stlzwdjdh" placeholder="请输入铁离子稳定剂代号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="铁离子稳定剂加量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="stlzwdjjl">
              <a-input v-model="model.stlzwdjjl" placeholder="请输入铁离子稳定剂加量"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'YtsjPfbForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/YtsjPfb/ytsjPfb/add",
          edit: "/YtsjPfb/ytsjPfb/edit",
          queryById: "/YtsjPfb/ytsjPfb/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }
         
        })
      },
    }
  }
</script>